package program

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'GET'
        url value(consumer(regex('/api/programs/\\d+/tutors')),
                producer('/api/programs/1/tutors'))
        headers {
            contentType(applicationJsonUtf8())
        }
    }
    response {
        status 200
        body("""
            [{
                "id":1,
                "mobilePhone":"132456453423214564475",
                "email":"1@1.com",
                "username":"11"
            }]
        """)
        bodyMatchers {
            jsonPath('$.[*]',byType())
            jsonPath('$.[*].id',byRegex(number()))
            jsonPath('$.[*].mobilePhone',byRegex(nonEmpty()))
            jsonPath('$.[*].email',byRegex(nonEmpty()))
            jsonPath('$.[*].username',byRegex(nonEmpty()))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }

}